<template>
	<div>
		<el-table :data="tableData" border style="width: 100%">
			<el-table-column prop="sname" label="姓名" width="120"></el-table-column>
			<el-table-column prop="ssex" label="性别" width="120"></el-table-column>
			<el-table-column prop="sage" label="年龄" width="120"></el-table-column>
			<el-table-column prop="stime" label="时间" width="300"></el-table-column>
			<el-table-column prop="sphone" label="手机号" width="120"></el-table-column>
			<el-table-column prop="classInfo.cname" label="班级" width="120"></el-table-column>
			<el-table-column label="操作" width="150">
				<template slot-scope="scope">
					<!--<el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button> -->
					<el-button @click="openLook(scope.row)" type="text" size="small">查看</el-button>
					<el-button @click="openUpdate(scope.row)" type="text" size="small">编辑</el-button>
					<el-button @click="onDelete(scope.row)" type="text" size="small">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
	</div>
</template>

<script>
	/* 引入api配置 */
	import apiConfig from '../config/global.js';
export default {
	props:['tableData'],
	data() {
		return {
		};
	},
	methods: {
		/* 点击查看按钮 */
		openLook(val) {
			this.$parent.$refs.dialog.dialogFormVisible = true;
			this.$parent.form = val;
			this.$parent.isLook = true; // 查看属性
			this.$parent.fromTitle = '查看学生信息'; //给打开的dialog设置title
			this.$parent.isUpdate = false; // 点前点击的是修改按钮
		},
		/* 点击编辑按钮 */
		openUpdate(val) {
			/* 更改数据框是否显示的属性 */
			this.$parent.$refs.dialog.dialogFormVisible = true;
			this.$parent.form = val;
			this.$parent.isLook = false; // 查看属性
			this.$parent.fromTitle = '编辑学生信息'; //给打开的dialog设置title
			this.$parent.formEmpData = Object.assign({}, this.form); //使用该方法时 数据就不会发生双向绑定了
			this.$parent.isUpdate = true; // 点前点击的是修改按钮
		},
		onDelete(row) {
			/* 处理post问题 这是个案例但是有问题 */
			var params = new URLSearchParams();
			params.append('ids', row.sid);
			
			this.$parent.$confirm('是否移除该项?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消'
			})
				.then(() => {
					this.$parent.axiosPost(apiConfig.stuDeleteApi, params);
				})
				.catch((e) => {
					console.log(e)
					this.$parent.$message({
						type: 'info',
						message: '删除取消'
					});
				});

			//this.TestAxios('post',apiConfig.stuDeleteApi,params);
		}
	}
};
</script>

<style></style>
